﻿Imports _1065144_1065164.DataProvider
Imports System.Data.SqlClient
Imports System.Data
Public Class ThongTinNhaDAO
    Public Shared Function GetAll() As DataTable
        Dim listThongTinNha As New DataTable()
        Dim cn As SqlConnection = New SqlConnection(_strConnectionString)
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "ketThongTinNhaThuevaLoaiNha"
        cmd.Connection = cn

        Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
        da.Fill(listThongTinNha)


        Return listThongTinNha
    End Function


    Public Shared Function HienThiGidView() As DataTable
        Dim listThongTinNha As New DataTable()
        Dim cn As SqlConnection = New SqlConnection(_strConnectionString)
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "HienThiGidView"
        cmd.Connection = cn

        Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
        da.Fill(listThongTinNha)


        Return listThongTinNha
    End Function

    Public Shared Sub Insert(ByVal sqlparameters As SqlParameter())
        Dim cn As SqlConnection = New SqlConnection(_strConnectionString)
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "themnha"
        cmd.Parameters.AddRange(sqlparameters)
        cmd.Connection = cn
        cn.Open()
        cmd.ExecuteNonQuery()
        cn.Close()

    End Sub
    Public Shared Sub Update(ByVal sqlparameters As SqlParameter())
        Dim cn As SqlConnection = New SqlConnection(_strConnectionString)
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "SuaThongTinNha"
        cmd.Connection = cn
        cmd.Parameters.AddRange(sqlparameters)
        cn.Open()
        cmd.ExecuteNonQuery()
        cn.Close()
    End Sub
    Public Shared Sub Delete(ByVal sqlparameters As SqlParameter)
        Dim cn As SqlConnection = New SqlConnection(_strConnectionString)
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "usp_XoaThongTinNha"
        cmd.Connection = cn
        cmd.Parameters.Add(sqlparameters)
        cn.Open()
        cmd.ExecuteNonQuery()
        cn.Close()
    End Sub


    Public Shared Function TKTheoMaNha(ByVal paraID As SqlParameter) As DataTable
        Dim listThongTinNha As New DataTable()
        Dim cn As SqlConnection = New SqlConnection(_strConnectionString)
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "timkiemmanha"
        cmd.Parameters.Add(paraID)
        cmd.Connection = cn

        Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
        da.Fill(listThongTinNha)
        Return listThongTinNha
    End Function


    Public Shared Function TKTheoLoaiNha(ByVal paraID As SqlParameter) As DataTable
        Dim listThongTinNha As New DataTable()
        Dim cn As SqlConnection = New SqlConnection(_strConnectionString)
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "timkiemloainha"
        cmd.Parameters.Add(paraID)
        cmd.Connection = cn

        Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
        da.Fill(listThongTinNha)
        Return listThongTinNha
    End Function
End Class

